<?php
class companyAction extends rareAction{
	public function execute(){
		$info = service_company::getInfo();
		$dao = new DaoImage();
		$images = $dao->getOne("typeID='".service_type::COMPANY."'");
		if(!empty($images)){
			$this->assign('images',array($images));
		}
		$this->assign('info',$info);
	}
	public function executePost(){
		$info = $this->getPostParam('info',array());
		$images = $this->getPostParam('img',array());
		if(!empty($images)){
			$dao = new DaoImage();
			$imgs = $dao->getOne("typeID='".service_type::COMPANY."'");
			if(empty($imgs)){
				service_image::insert($images,service_type::COMPANY);
			}else{
				$dao->update("id='".$imgs['id']."'",array('src'=>$images[0]));
			}
		}
		service_company::save($info);
		jsonReturn(1,'ok');
	}
}
?>
